package com.jlpay.openapi.demo.trans.common;

import com.jlpay.open.jlpay.sdk.java.model.trans.common.request.RefundRequest;
import com.jlpay.open.jlpay.sdk.java.model.trans.common.response.RefundResponse;
import com.jlpay.open.jlpay.sdk.java.utils.json.JsonUtils;
import com.jlpay.openapi.demo.JlpayOpenApiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author dengwenning
 * @since 2024/9/23
 **/
public class RefundService {
    private static final Logger LOGGER = LoggerFactory.getLogger(RefundService.class);

    public static void main(String[] args) {
        RefundRequest refundRequest = buildRefundRequest();
        RefundResponse refundResponse = JlpayOpenApiService.openMerchService()
                .post(refundRequest, RefundResponse.class);
        LOGGER.info("订单退款响应:{}", JsonUtils.toString(refundResponse));
    }

    private static RefundRequest buildRefundRequest() {
        RefundRequest refundRequest = new RefundRequest();

        refundRequest.setMchId("849584358120018");
        refundRequest.setOutTradeNo("ld201911023465529");
        refundRequest.setOriOutTradeNo("ld2019102216465525");
        refundRequest.setOriTransactionId("80011557201909171853011568");
        refundRequest.setTotalFee("1");
        refundRequest.setRemark("该订单物流请走顺丰快递");
        refundRequest.setMchCreateIp("123.12.12.123");
        refundRequest.setLongitude("116.078631");
        refundRequest.setLatitude("39.71274");

        return refundRequest;
    }
}
